package cn.thinkluck.pattern.visitor;

import cn.thinkluck.pattern.visitor.computer.ComputerImpl;
import cn.thinkluck.pattern.visitor.computer.KeyboardImpl;
import cn.thinkluck.pattern.visitor.computer.MouseImpl;
import cn.thinkluck.pattern.visitor.visitor.ComputerDisplayVisitorImpl;
import cn.thinkluck.pattern.visitor.visitor.ComputerDriveVisitor;

/**
 * 访问者模式
 * 为固有的实体，比如电脑，设计行为，传入不同的访问产生不同的结果
 * @Author liutao
 * @DateTime 2024/8/4 下午2:52
 */
public class Main {
    public static void main(String[] args) {
        MouseImpl mouse = new MouseImpl();
        //鼠标执行展示的访问
        mouse.accept(new ComputerDisplayVisitorImpl());
        KeyboardImpl keyboard = new KeyboardImpl();
        //键盘执行更新驱动的访问
        keyboard.accept(new ComputerDriveVisitor());
        ComputerImpl computer = new ComputerImpl();
        //电脑执行展示的访问
        computer.accept(new ComputerDisplayVisitorImpl());
    }
}
